<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Core\Traits\Database\SchemaCommentTrait;

class CreateNewsTable extends Migration
{
    use SchemaCommentTrait;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('news', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('记录ID');
            $table->string('title', 100)->comment('新闻标题')->index();
            $table->string('author', 100)->comment('新闻作者')->index();
            $table->string('from_desc', 100)->comment('来源描述')->index();
            $table->string('from_url', 128)->comment('新闻来源链接')->index();
            $table->string('comment', 100)->comment('备注')->index();
            $table->tinyInteger('has_meta')->default(0)->comment('新闻是否有其他信息 enum[0:没有,1:有]')->index();
            $table->tinyInteger('state')->default(0)->comment('状态,enum[-2:放弃,-1:失败,0:待爬取,1:爬取中,2:已完成]')->index();
            $table->date('news_date')->comment('新闻发布日期')->index();
            $table->dateTime('created_at')->nullable(false)->comment('创建时间');
            $table->dateTime('updated_at')->nullable(false)->comment('更新时间');
            $table->dateTime('deleted_at')->nullable(true)->comment('删除时间');
        });
        $this->comment('news', '新闻基础信息存储记录表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('news');
    }
}
